//
//  ViewController.m
//  ScoreGame
//
//  Created by 黄裕杰 on 16/8/19.
//  Copyright © 2016年 黄裕杰. All rights reserved.
//

#import "ViewController.h"
#import <JavaScriptCore/JavaScriptCore.h>
#import "WHUCalendarView.h"
#import "rootViewController.h"

#import "SSDKUserRule.h"

@interface ViewController ()<UIWebViewDelegate>{
    
    UIActivityIndicatorView *myIndicator;
    UIWebView *myWebView;
}

@property (strong,nonatomic) WHUCalendarView *calview;
@property (nonatomic, strong) UIButton *adBtn;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    loadBGImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -64, ScreenW, ScreenH)];
    [self.view addSubview:loadBGImageView];
    if (ScreenH == 480) {
        loadBGImageView.image = [UIImage imageNamed:@"default@2x"];
        
    }else{
        loadBGImageView.image = [UIImage imageNamed:@"default-750"];
        
    }
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.title = @"日历";
    self.view.backgroundColor = [UIColor whiteColor];
    //添加视图
    self.calview = [[WHUCalendarView alloc]initWithFrame:CGRectMake(0, 64, ScreenW, ScreenH-64)];
    [self.view addSubview:self.calview];
    UIButton *calendarBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    calendarBtn.frame = CGRectMake(ScreenW/2-60, ScreenH - 140, 120, 40);
    [calendarBtn setBackgroundColor:[UIColor colorWithRed:79/255. green:178/255. blue:253/255. alpha:1]];
    [calendarBtn setTitle:@"查看备忘录" forState:UIControlStateNormal];
    [calendarBtn addTarget:self action:@selector(note) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:calendarBtn];
    
    _calview.onDateSelectBlk = ^(NSDate* date){
        NSDateFormatter *format = [[NSDateFormatter alloc] init];
        [format setDateFormat:@"yyyy年MM月dd"];
        NSString *dateString = [format stringFromDate:date];
        NSLog(@"xxxcalview:%@",dateString);
    };

    [self addAdView];
}

-(void)note
{
    rootViewController *rootV = [[rootViewController alloc]init];
    [self.navigationController pushViewController:rootV animated:YES];

}

#pragma mark ======================= 添加广告图 ==============================
- (void)addAdView
{
//    CGRect rect = CGRectMake(0, ScreenH - 60, ScreenW, 60);
//    UIButton *imageViewBtn = [[UIButton alloc]initWithFrame:rect];
//    [imageViewBtn setTitle:@"新闻资讯,精彩生活" forState:UIControlStateNormal];
//    [imageViewBtn addTarget:self action:@selector(bannerClick) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:imageViewBtn];
//    
//    [imageViewBtn setBackgroundColor:[UIColor colorWithRed:79/255. green:178/255. blue:253/255. alpha:1]];
//    
//    UIView *adview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 24, 24)];
//    [imageViewBtn addSubview:adview];
//    
//    UIImageView *imageView = [[UIImageView alloc]initWithFrame:adview.frame];
//    imageView.image = [UIImage imageNamed:@"ad"];
//    [adview addSubview:imageView];
}

- (void)bannerClick
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.qq.com/"]];
}
@end
